package com.jz.community.modulemine.packet.presenter;

import com.jz.community.basecomm.mvp.BaseLifeCyclePresent;
import com.jz.community.basecomm.net.rxandroid.OnLoadListener;
import com.jz.community.modulemine.packet.bean.RedPacketBean;
import com.jz.community.modulemine.packet.model.RedPacketModel;
import com.jz.community.modulemine.packet.model.RedPacketModelImp;
import com.jz.community.modulemine.packet.ui.RedPacketView;

public class RedPacketPresenter extends BaseLifeCyclePresent<RedPacketView.View> implements RedPacketView.Presenter {

    private RedPacketView.View view;
    private RedPacketModel model;

    public RedPacketPresenter(RedPacketView.View view) {
        this.view = view;
        this.model = new RedPacketModelImp(view.getContext());
    }

    @Override
    public void initPacketData(int status, int page, int size) {
        model.initRedPacketData(status, page, size, new OnLoadListener<RedPacketBean>() {
            @Override
            public void onSuccess(RedPacketBean redPacketBean) {
                view.showRedPacket(redPacketBean);
            }

            @Override
            public void onFail(String msg, int code) {
                view.showError(msg);

            }
        });

    }
}
